package com.ayoka.mvp;

import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.bean.BaseResponse;
import com.ayoka.bean.CouponBean;
import com.ayoka.bean.CourseBean;
import com.ayoka.bean.PagerBean;
import com.ayoka.http.API;
import com.ayoka.http.OkHttpListener;
import com.jcp.baselibrary.utils.UIUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface CouponMVP {

    interface CouponModel {

    }

    interface ICouponView extends IBaseView {

        void configCouponListData(List<CouponBean> listData);
    }

    class CouponPresenter extends BasePresenter<ICouponView> {

        public void getCouponListData(boolean isShowWaitDialog) {
            if (isShowWaitDialog) {
                mViewRef.get().showWaitDialog(UIUtils.getString(R.string.loading));
            }
            API.getCouponListData(this, new OkHttpListener<BaseResponse<List<CouponBean>>>() {
                @Override
                public void onSuccess(BaseResponse<List<CouponBean>> response) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().configCouponListData(response.data);
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().showToast(errorMessage);
                }
            });
        }

    }

}
